#!/usr/bin/env python
# coding=utf-8
#__author__ = 'Yunchao Ling'

import redis
import sys
import random
import time

names=[]
infile=open("desc2015.txt","r")
for line in infile:
    line=line.rstrip()
    name=line.split("\t")[2]
    names.append(name)
infile.close()

max=int(sys.argv[1])
counts=len(names)
count=0
time1=time.time()
r = redis.StrictRedis(host='localhost', port=6379, db=1)
while count<max:
    thisis=r.get(names[random.randint(0,counts-1)])
    count+=1
time2=time.time()
print(str(time2-time1))